package com.summer.study.leetcode.tree;

/**
 * @auther: 杨杰
 * @date: 2019/7/31 11:40
 * @description:
 */
public class TreeUtil {

    /**
     *         5
     *    1         4
     *           3       6
     *       9
     */
    public static void createIntegerTreeNodes(Tree<Integer> tree) {
        Node<Integer> treeNode9 = new BinaryTreeNode(9, null, null);
        Node<Integer> treeNode1 = new BinaryTreeNode(1, null, null);
        Node<Integer> treeNode6 = new BinaryTreeNode(6, null, null);
        Node<Integer> treeNode3 = new BinaryTreeNode(3, treeNode9, null);
        Node<Integer> treeNode4 = new BinaryTreeNode(4, treeNode3, treeNode6);
        Node<Integer> root = new BinaryTreeNode(5, treeNode1, treeNode4);
        tree.init(root);
    }

    public static void createSymmetricTreeNodes(Tree<Integer> tree) {
        Node<Integer> treeNodeD = new BinaryTreeNode('3', null, null);
        Node<Integer> treeNodeE = new BinaryTreeNode('4', null, null);
        Node<Integer> treeNodeF = new BinaryTreeNode('4', null, null);
        Node<Integer> treeNodeG = new BinaryTreeNode('3', null, null);

        Node<Integer> treeNodeB = new BinaryTreeNode('2', treeNodeD, treeNodeE);
        Node<Integer> treeNodeC = new BinaryTreeNode('2', treeNodeF, treeNodeG);

        Node<Integer> treeNodeA = new BinaryTreeNode('1', treeNodeB, treeNodeC);
        tree.init(treeNodeA);
    }

    /**
             A
        B         C
     D     E     F    G
     * */
    public static void createCharacterTreeNodes(Tree<Character> tree) {
        Node<Character> treeNodeD = new BinaryTreeNode('D', null, null);
        Node<Character> treeNodeE = new BinaryTreeNode('E', null, null);
        Node<Character> treeNodeF = new BinaryTreeNode('F', null, null);
        Node<Character> treeNodeG = new BinaryTreeNode('G', null, null);

        Node<Character> treeNodeB = new BinaryTreeNode('B', treeNodeD, treeNodeE);
        Node<Character> treeNodeC = new BinaryTreeNode('C', treeNodeF, treeNodeG);

        Node<Character> treeNodeA = new BinaryTreeNode('A', treeNodeB, treeNodeC);
        tree.init(treeNodeA);
    }

}
